package com.navi.loaddata.loadService.impl.mesData.glassSumData;

import com.navi.loaddata.core.mysqlEntity.EtlConfDModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoadCShtOpeSumService {
    private static final Logger logger = LoggerFactory.getLogger(LoadCShtOpeSumService.class);
    @Autowired
    private AmqpTemplate rabbitTemplate;
    @Autowired
    private LoadCPanelSumBean loadCPanelSumBean;


    public String[] LoadCShtOpeSumMain(EtlConfDModel etlConfD) throws Exception {
        String[] resMsg = LoadCShtOpeSum(etlConfD);
        logger.info("LoadCShtOpeSumMain finish");
        return resMsg;
    }

    private String[] LoadCShtOpeSum(EtlConfDModel etlConfD) throws Exception {
        String[] resMsg = new String[3];
        int okCnt = 0;
        int errCnt = 0;
        String errMsg = null;

        //将wpp_cdefect_panel_sum表对应时间段内的数据删除
        loadCPanelSumBean.DeleteCPanelSumData(etlConfD, errMsg, errCnt);

        //向wpp_cdefect_panel_sum表插入数据
        loadCPanelSumBean.InsertCPanelSumData(etlConfD, errMsg, errCnt);


        resMsg[0] = String.valueOf(okCnt);
        resMsg[1] = String.valueOf(errCnt);
        resMsg[2] = errMsg;

        return resMsg;
    }
}
